package com.bst.bsj.common.dal.ibatis;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.bst.bsj.common.dal.daointerface.DistrictDAO;
import com.bst.bsj.common.dal.dataobject.Area;
import com.sylinxsoft.tools.dao.impl.CommonBaseDAOImpl;

@Service("districtDAO")
public class DistrictDAOImpl extends CommonBaseDAOImpl implements DistrictDAO {

  @Override
  public Long getCounts(Map paramMap) {
    return (Long) getSqlMapClientTemplate().queryForObject(getNameSpace() + ".MS_QUERY_COUNT", paramMap);
  }

  @Override
  public List<Area> selectAll(Map paramMap, Long offset, Long length) {
    paramMap.put("offset", offset);
    paramMap.put("length", length);
    return (List<Area>) this.getSqlMapClientTemplate().queryForList(getNameSpace() + ".MS_QUERY_PAGE", paramMap);
  }

  @Override
  public Area getArea(Long id) {
    return (Area) getSqlMapClientTemplate().queryForObject(getNameSpace() + ".MS_SELECT", id);
  }

  @Override
  public int update(Area area) {
    return getSqlMapClientTemplate().update(getNameSpace() + ".MS_UPDATE", area);
  }

  @Override
  public Long insert(Area area) {
    return (Long) getSqlMapClientTemplate().insert(getNameSpace() + ".MS_INSERT", area);
  }

  @Override
  public int delete(Long id) {
    return getSqlMapClientTemplate().delete(getNameSpace() + ".MS_DELETE", id);
  }

  @Override
  public List<Area> getAreas(String type) {
    return (List<Area>) this.getSqlMapClientTemplate().queryForList(getNameSpace() + ".MS_AREAS", type);
  }

  @Override
  public Area getAreaByCity(Map paramMap) {
    return (Area) getSqlMapClientTemplate().queryForObject(getNameSpace() + ".MS_GETAREABYCITY", paramMap);
  }

  @Override
  public List<Area> getAreasByParent(Map<String,Object> paramMap) {
    return (List<Area>) this.getSqlMapClientTemplate().queryForList(getNameSpace() + ".MS_GETAREASBYPARNET", paramMap);
  }

}
